﻿CREATE TABLE [dbo].[PurchaseLogItem] (
    [PurchaseId]           UNIQUEIDENTIFIER NOT NULL,
    [Id]                   UNIQUEIDENTIFIER CONSTRAINT [DF_PurchaseLogItem_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL,
    [Product]              UNIQUEIDENTIFIER NOT NULL,
    [IsDiscount]           BIT              NOT NULL,
    [Quantity]             INT              NOT NULL,
    [PricePerItem]         MONEY            NOT NULL,
    [PricePerAmountUnit]   MONEY            NOT NULL,
    [PricePerQuantityUnit] MONEY            NOT NULL,
    [Note]                 NVARCHAR (300)   NULL,
    CONSTRAINT [PK_PurchaseLogItem] PRIMARY KEY CLUSTERED ([PurchaseId] ASC, [Id] ASC),
    CONSTRAINT [FK_PurchaseLogItem_Product] FOREIGN KEY ([Product]) REFERENCES [dbo].[Product] ([Id]),
    CONSTRAINT [FK_PurchaseLogItem_PurchaseLog] FOREIGN KEY ([PurchaseId]) REFERENCES [dbo].[PurchaseLog] ([Id])
);

